package com.topup.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.topup.pojo.Admininfo;
import com.topup.pojo.User;
import com.topup.service.AdmininfoService;
import com.topup.until.Result;

@Controller
@RequestMapping("admin")
public class AdmininfoController {
	@Autowired
	private AdmininfoService AService;
	
	
	@RequestMapping("Adminlogin")
	@ResponseBody
	 public Result Adminlogin(HttpServletRequest request, HttpServletResponse response) throws  Exception{
        Admininfo A;
        Result r=new Result();
        String name1=request.getParameter("username");
        String pwd1=request.getParameter("userpwd");
        System.out.println("123123");
        System.out.println("name:"+name1);
        System.out.println("pwd:"+pwd1);

       A=AService.adminlogin(name1, pwd1);
        System.out.println("123"+A);
        if(A!=null){
            r.setStatus("0");
            System.out.println("状态码+"+r.getStatus());
            request.getSession().setAttribute("admin",A );
           Admininfo uu = (Admininfo) request.getSession().getAttribute("admin");
           request.setAttribute("u",uu);
            //鍒涘缓cookie1锛屼负鍏舵寚瀹氶敭鍚嶆槸userName锛屽�兼槸杈撳叆鐨勭敤鎴峰悕銆�
            r.setMsg("鐧婚檰");

        }else{
            r.setStatus("1");
            r.setMsg("鐧婚檰澶辫触,璇锋鏌ヨ处鍙锋垨鑰呭瘑鐮�");
        }

 
        return r;
    }
	
}
